<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品规格详情</title>
</head>
<script>

</script>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>详情查看</legend>
</fieldset>
    <form class="layui-form layui-form-pane" action="" id="form1">
        <input type="hidden" id="id" name="ct.id">
        <div class="layui-form-item">
            <label class="layui-form-label">速别</label>
            <div class="layui-input-inline">
                <input type="text" name="ct.type" lay-verify="required|number" placeholder="请输入" autocomplete="off" class="layui-input" id="type">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">规格名称</label>
            <div class="layui-input-inline">
                <input type="text" name="ps.name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" id="name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">颜色</label>
            <div class="layui-input-inline">
                <input type="text" name="ct.color" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" id="color">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最大节数</label>
            <div class="layui-input-inline">
                <input type="text" name="ct.maxSection" lay-verify="required|number" placeholder="请输入" autocomplete="off" class="layui-input" id="maxSection">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最小节数</label>
            <div class="layui-input-inline">
                <input type="text" name="ct.minSection" lay-verify="required|number" placeholder="请输入" autocomplete="off" class="layui-input" id="minSection">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">结尾方式</label>
            <div class="layui-input-block">
                <input type="radio" name="ct.method" value="true" title="是" id="method1">
                <input type="radio" name="ct.method" value="false" title="否" id="method2">
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-filter="save" lay-submit="">保存</button>
            <button class="layui-btn" lay-filter="back" type="button">返回</button>
        </div>
    </form>

</body>
<script>
    layui.use(['element', 'layer','form'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,form = layui.form

        form.render();
    });
    var objdata = parent.objdata;
    $.post(
        "/ct/query",{
            id: objdata,
            page:1,
            limit:10
        },function (res) {
            var obj = res.data;
            var code = res.code;
            var id = objdata;
            var type = obj[0].ct.type;
            var name = obj[0].ps.name;
            var color = obj[0].ct.color;
            var maxSection = obj[0].ct.maxSection;
            var minSection = obj[0].ct.minSection;
            var method = obj[0].ct.method;
            if (code == 0){
                $("#id").attr('value',id);
                $("#type").attr('value',type);
                $("#name").attr('value',name);
                $("#color").attr('value',color);
                $("#maxSection").attr('value',maxSection);
                $("#minSection").attr('value',minSection);
                if (method == true){
                    var a = $("#method1");
                    a.next().click();
                }else {
                    var b = $("#method2");
                    b.next().click();
                }
            }else {
                alert("未找到数据");
            }
        }
    );
    $(".layui-btn :eq(1)").on("click",function () {
        toJumpGet($('.layui-body'),"/pages/ct/ctList.html");
    });
    layui.form.on('submit(save)', function(data){
        $.post(
            "/ct/update", $("#form1").serialize(), function (res) {
                //判断
                if (res.code == 0){
                    toJumpGet($('.layui-body'),"/pages/ct/ctList.html");
                } else {
                    layer.alert(res.msg);
                }
            }
        );
    });
</script>
</html>